import {Directive ,ElementRef,Input,HostListener} from "@angular/core";

@Directive({
    selector:'[YellowBg3]'
})
export class YellowBg3{
    private _defaultColor='yellow';
    private el:HTMLElement;
    @Input('YellowBg3') backgroundColor:string;
    constructor(el:ElementRef){
        this.el=el.nativeElement;
        this.setStyle(this._defaultColor)
    }
    @HostListener('click') onclick(){
        this.setStyle(this.backgroundColor||this._defaultColor);
    }
    private setStyle(color:string){
        this.el.style.backgroundColor=color;
    }
}